<?php
namespace app\common\model;
use x\Xbase;
class ComAddress extends Xbase
{
    /**
     * 获取省市区地址
     * @param  [type] $id    [区县id]
     * @return [type]        [description]
     */
    public function getAddress($id){
        $sql = '
            select
                a.name as atitle,
                b.name as btitle,
                c.name as ctitle
            from
                com_address a
            left join
                com_address b
            on
                a.parent_id = b.id
            left join
                com_address c
            on
                b.parent_id = c.id
            where
                a.id = ?';
        $rs = $this->db->query($sql,[$id],1);
        if($rs){
            return $rs['atitle'].' '.$rs['btitle'].' '.$rs['ctitle'];
        }else{
            return "";
        }
    }
}
